package hd3.examples;

import hdapi3.HD3;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DevicesExample extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		Utility.initHDAPISettings(this.getServletContext());
		response.setContentType("text/html");

		PrintWriter out = response.getWriter();

		HD3 hd = new HD3();
		out.println("<h1>Vendors</h1><p>");
		if (hd.deviceVendors()) {
			out.println(hd.getReply().toString());
		} else {
			out.println(hd.getError());
		}
		out.println("</p>");
		
		out.println("<h1>Nokia Models</h1><p>");
		if (hd.deviceModels("Nokia")) {
			out.println(hd.getReply().toString());
		} else {
			out.println(hd.getError());
		}
		out.println("</p>");
		
		out.println("<h1>Nokia N95 Properties</h1><p>");
		if (hd.deviceView("Nokia", "N95")) {
			out.println(hd.getReply().toString());
		} else {
			out.println(hd.getError());
		}
		out.println("</p>");
		
		out.println("<h1>Handsets with CDMA Support</h1><p>");
		if (hd.deviceWhatHas("network", "CDMA")) {
			out.println(hd.getReply().toString());
		} else {
			out.println(hd.getError());
		}
		out.println("</p>");
		
		out.close();
		
	}
}
